﻿using System;
using System.Collections;
using System.Data;
using FrameworkManapro.BusinessModel;

namespace GMAC.ReportingSystem.DataAccess
{
    public class ReportDataAccess
    {

        #region Public Methods

        public Business.Entities.ReportCollection GetList(String ReportProjectName)
        {
            var parameters = new ArrayList() { ReportProjectName };
            var dt = DataAccessComponent.ExecuteSelect("procReportSelect", parameters);
            var reports = new Business.Entities.ReportCollection();

            if (dt != null && dt.Rows.Count > 0)
            {
                Business.Entities.Report report;
                foreach (DataRow row in dt.Rows)
                {
                    report = new Business.Entities.Report()
                    {
                        ReportID = (Guid)row["ReportID"],
                        Name = row["Report Description"].ToString(),
                        Path = row["Report Name"].ToString()
                    };
                    reports.Add(report);
                }
            }
            return reports;
        }
        public Business.Entities.Report GetDetails(String ReportProjectName, String ReportName)
        {
            var ReportDetail = new Business.Entities.Report();
            var parameters = new ArrayList() { ReportProjectName, ReportName };
            var result = DataAccessComponent.ExecuteSelect("procReportByNameSelect", parameters);
            if (result != null && result.Rows.Count > 0)
            {
                var row = result.Rows[0];
                ReportDetail.Name = row.ItemArray[1].ToString();
                ReportDetail.Path = row.ItemArray[0].ToString();
            }
            return ReportDetail;

        }

        #endregion

    }
}
